<template>
  <el-dialog
    title="新建企业"
    :visible.sync="dialogVisible"
    width="30%"
  >
    <span>
      <ul>
        <li>
          <span>企业名称:</span>
          <input type="text" placeholder="(必填)"  v-model="ename">
        </li>
        <li style="margin: 10px 0">
         <span>联系人:</span>
          <input type="text" placeholder="(必填)" v-model="econtact">
        </li>
        <li style="margin-bottom:10px ;">
         <span>联系电话:</span>
          <input type="text" placeholder="(必填)用作企业登录账号" v-model="ephone">
        </li>
        <li>
          <span>登录密码:</span><input type="text" placeholder="password" v-model="epassword">
        </li>
        <li style="width: 100%;margin-top: 10px">
          <span style="margin-left: 19%">{{tip}}</span>
        </li>
      </ul>
    </span>
    <span slot="footer" class="dialog-footer" style="display: flex;justify-content: center;align-items: center">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="save">确 定</el-button>
  </span>
  </el-dialog>
</template>

<script>
/*eslint-disable*/
import {checkStatus,getEdit} from  "../../utils/enterpriselist";

export default {
    name:"index",
    data() {
      return {
        itemlist:{},
        ename:'',
        ephone:'',
        econtact:'',
        epassword:'',
        dialogVisible: false
      };
    },
    props: {
      tip: {
        type: String,
        default: "注：密码初始统一为：123456"
      },
    },
    methods: {
      changeDisable(data){
        console.log(data);
        this.itemlist=data;
        this.ename=data.userName;
        this.econtact=data.contacts;
        this.ephone=data.phone;
        this.dialogVisible=true
      },
      save(){
        console.log(111);
        let data={
          "id":this.itemlist.id,
          "userCode": this.itemlist.userCode,
          "userName": this.ename,
          "password": this.epassword,
          "contacts": this.econtact,
          "phone": this.ephone,
          "loginLock":this.itemlist.loginLock
        };
        getEdit('/update',data).then(rawRes=>rawRes.data).then(res=>{
            if (res=='success'){
              console.log("1111");
              this.$emit('changedDate',data)
            }
        });
        this.dialogVisible = false
        // checkStatus("http://192.168.0.135:8080/user/update","post",{
        //   id:this.id,
        //   userName:this.ename,
        //   phone:this.ephone,
        //   contacts:this.econtact,
        //   password:this.epassword
        // }).then(res=>res.data).then(res=>{
        //   console.log(res);
        // })
      }
    },

  };
</script>

<style scoped>
  ul{
    padding: 0;
  }
  li{
    list-style:none;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  li>input{
    width: 80%;
    font-size: 12px;
    color: #3c3c3c;
    height: 35px;
  }
</style>
